﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Brunch.Forms
{
	public partial class BaseEditForm : Form
	{
		public BaseEditForm()
		{
			InitializeComponent();
			btnCancel.Left = this.Width - btnCancel.Width - 12;
			btnOK.Left = btnCancel.Left - btnOK.Width - 6;
			btnOK.DialogResult = DialogResult.None;
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			bool isValid = false;
			try
			{
				isValid = IsValid();
			}
			catch (ApplicationException ex)
			{
				Common.ShowError(ex.Message);
				isValid = false;
			}
			if (isValid)
				this.DialogResult = DialogResult.OK;
		}

		protected virtual bool IsValid()
		{
			return true;
		}
	}
}
